﻿Imports System.Net
Imports System.Threading

Public Class about
    Dim returnValue As String
    Private Sub about_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Show()
        Updatecheck()
        Label1.Location = New Point(Me.Width \ 2 - Label1.Width \ 2, Label1.Top)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error Resume Next
        If Button1.BackColor = Color.Silver Then
            Exit Sub
        Else
        End If
        If System.IO.File.Exists("releaseup100.exe") Then
            Process.Start("releaseup100.exe")
            End
        Else
            My.Computer.Network.DownloadFile("https://drsshm.googlecode.com/files/releaseup100", "releaseup100.exe")
            If System.IO.File.Exists("releaseup100.exe") Then
                MsgBox("The updater has downloaded. Press 'OK' to start. You may see a command promt screen appear briefly.")
                Process.Start("releaseup100.exe")
                End
            End If
        End If
        If Err.Number <> 0 Then
            MsgBox("The update did not work:" & vbCrLf & Err.Description & vbCrLf & Err.Source, vbOKOnly - vbExclamation, +"This might mean that you are not connected to the internet, or Mr. Slone hates you.")
        Else
        End If
    End Sub

    Private Sub LinkLabel1_LinkClicked(sender As System.Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Dim url As String = "https://code.google.com/p/drsshm"
        Process.Start(url)
    End Sub

    Private Sub Label1_Click(sender As System.Object, e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub Updatecheck()
        If My.Computer.Network.IsAvailable Then
            Dim instance As WebClient = New WebClient
            Dim address As String = "https://drsshm.googlecode.com/files/rv.kuf"
            returnValue = instance.DownloadString(address)
        Else
            MsgBox("You are not connected to the Internet.")
        End If
        If returnValue = "1.0.0.0" Then
            Label3.Text = "No new updates"
            Button1.BackColor = Color.Silver
            Label3.Location = New Point(Me.Width \ 2 - Label3.Width \ 2, Label3.Top)
        Else
            Label3.Text = "New update: " + returnValue
            Label3.Location = New Point(Me.Width \ 2 - Label3.Width \ 2, Label3.Top)
        End If
        If returnValue = "" Then
            Label3.Text = "Connection error!"
            Label3.Location = New Point(Me.Width \ 2 - Label3.Width \ 2, Label3.Top)
            Button1.BackColor = Color.Silver
        End If
        If returnValue.Chars(0) = "<" Then
            Label3.Text = "Login to network!"
            Label3.Location = New Point(Me.Width \ 2 - Label3.Width \ 2, Label3.Top)
            Button1.BackColor = Color.Silver
        End If
    End Sub
   
    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, _
      ByVal e As System.ComponentModel.DoWorkEventArgs) _
      Handles BackgroundWorker1.DoWork

    End Sub

    Private Sub ThreadProcSafe()
        Throw New NotImplementedException
    End Sub

End Class
' © 2012 Matthew Kowal
'    This program is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 3 of the License, or
'    (at your option) any later version.

'    This program is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with this program.  If not, see <http://www.gnu.org/licenses/>